package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-05-08
 * Time: 14:10
 */
public class Computer {
    public void powerOn(){
        System.out.println("打开笔记本电脑!");
    }

    public void powerOff(){
        System.out.println("关闭笔记本电脑!");
    }

    public void useDevice(IUse use){
        use.openDevice();
        if(use instanceof Mouse){
            Mouse mouse = (Mouse)use;
            mouse.click();
        }else if(use instanceof KeyBoard){
            KeyBoard keyboard = (KeyBoard) use;
            keyboard.Input();
        }
        use.closeDevice();
    }
}
